package mains;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;

import app.Payment;

public class Main8QueryParameters {

    private static final String PERSISTENCE_UNIT_NAME = "CashM";
    private static EntityManagerFactory factory;
    public static void main(String[] args) {
	factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
	EntityManager em = factory.createEntityManager();
	
	
	TypedQuery<Payment> query = em.createQuery(
		"SELECT p FROM Payment p WHERE p.total > ?1", Payment.class);
	List<Payment> listM = null;
	try {
		query.setParameter(1, 750.0);
		listM = query.getResultList();
	}
	finally{em.close();}
	for(Payment p : listM) { System.out.println(p.toString()); }

    }

}
